package com.waleipt.api.es.tcptransport.message;

import java.io.IOException;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.transport.TransportRequest;

public class UserRequest extends TransportRequest
{
    public int id ;
    public String name ;
    public int age ;
    
    
    public UserRequest() {}
    
    public UserRequest( int id, String name, int age ) {
        this.id = id ;
        this.name = name ;
        this.age = age ;
        
    }
    
    @Override
    public void readFrom(StreamInput in) throws IOException {
//        super.readFrom(in);
        this.id = in.readInt() ;
        Text text = in.readText() ;
        this.name =  text.toString() ;
        this.age = in.readInt() ;
    }
    
    @Override
    public void writeTo(StreamOutput out) throws IOException {
//        super.writeTo(out);
        out.writeInt( this.id );
        out.writeText( new Text(this.name) );
        out.writeInt( age );
    }
    
}
